﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace SD.UI
{
    public class BasePage : System.Web.UI.Page
    {
        protected const String ERROR_SQL_EXCEPTION = "Database error occured ! Please try again later.";

        protected const String ERROR_DUPLICATE_NAME = "The Name is exist in the system. Please enter another name.";

        protected const String INFO_DATAHANDLE_SUCCESSFUL = "Database has been updated successful.";

        
        /// <summary>
        /// Show messgae box to user
        /// </summary>
        /// <param name="msg">Message to show</param>
        protected void ShowMessage(String msg)
        {
            String strScript = String.Format("ShowMsg('{0}')", msg);
            ScriptManager.RegisterStartupScript(this, typeof(Page), "Show", strScript, true);
        }

        /// <summary>
        /// Show messgae box to user and redirect to a page indicated by url param
        /// </summary>
        /// <param name="msg">Message to show</param>
        /// <param name="url">URL of the redirected page</param>
        protected void ShowMessageAndRedirect(String msg, String url)
        {
            String strScript = String.Format("ShowMsgAndRedirect('{0}', '{1}')", msg, url);
            ScriptManager.RegisterStartupScript(this, typeof(Page), "ShowAndRedirect", strScript, true);
        }
    }
}
